<#--声明表名称-->
<#assign tableName="${table.comment?replace('信息','')?replace('表','')}"/>

import amRequest from '../index'

import {I${entity}Data, I${entity}SearchQuery, Update${entity}Form} from './type'
import {IPageResult, IPageSearchForm} from '@/service/type'
import {IDataResult} from '../type'

enum BaseApi {
    BaseUrl = `/system/${controllerMappingHyphen}`
}

/**
 * 分页查询数据
 * @param searchForm 查询条件包括分页信息
 * @returns 分页结果信息
 */
export function pageSearchRequest(
    searchForm: IPageSearchForm<I${entity}SearchQuery>
) {
    return amRequest.get<IDataResult<IPageResult<I${entity}Data>>>({
        url: BaseApi.BaseUrl + `/${r'${searchForm.size}'}/${r'${searchForm.page}'}`,
        params: searchForm.otherOptions
    })
}

/**
 * 根据${tableName}ID删除${tableName}
 * @param id ${tableName}ID
 * @returns 结果
 */
export function deleteByIdRequest(id: string) {
    return amRequest.delete<IDataResult<boolean>>({
        url: BaseApi.BaseUrl + `/${r'${id}'}`
    })
}

/**
 * 添加${tableName}信息
 * @param userInfo ${tableName}信息
 * @returns 结果信息
 */
export function add${entity}Request(userInfo: I${entity}Data) {
    return amRequest.post<IDataResult<I${entity}Data>>({
        url: BaseApi.BaseUrl,
        data: userInfo
    })
}

/**
 * 修改${tableName}信息
 * @param userInfo ${tableName}信息
 * @returns 结果信息
 */
export function update${entity}ByIdRequest(updateForm: Update${entity}Form) {
    return amRequest.put<IDataResult<I${entity}Data>>({
        url: BaseApi.BaseUrl + `/${r'${updateForm.id}'}`,
        data: updateForm.updateModel
    })
}
